//
//  JsButtonLiiVm.m
//
//  Created by Gikki Ares on 2020/12/18.
//

#import "JsButtonLiiVm.h"
#import "JsGeometryManager.h"

@interface Prefix(ButtonLiiVm)()



@end

@implementation Prefix(ButtonLiiVm)

+(Prefix(ButtonLiiVm) *)sharedInstance {
	static dispatch_once_t onceToken;
	static JsButtonLiiVm * _sharedInstance;
	
	dispatch_once(&onceToken, ^{
		_sharedInstance = [[JsButtonLiiVm alloc] init];
	});
	return _sharedInstance;
}

+(Prefix(ButtonLiiVm) *)defaultVm {
	JsButtonLiiVm * ui = [[JsButtonLiiVm alloc] init];
	return ui;
}


+ (Prefix(ButtonLiiVm) *)defaultUnselectedVm {
	JsButtonLiiVm * vm = [[JsButtonLiiVm alloc] init];
	vm.size = CGSizeMake(50,50);
	
	return vm;
}

+(Prefix(ButtonLiiVm) *)defaultSelectedVm {
	JsButtonLiiVm * vm = [[JsButtonLiiVm alloc] init];
	vm.size = CGSizeMake(200,50);
	return vm;
}


- (instancetype)init {
	if(self = [super init]) {
		//所有frame初始化为CGRectNull
		self.foregroundImageViewFrame = CGRectNull;
		self.btnFrame = CGRectNull;
		self.backgroundImageViewFrame = CGRectNull;
		self.labelFrame = CGRectNull;
		
			//label
		self.labelTextColor = [UIColor blackColor];
		self.labelFont = [UIFont systemFontOfSize:12];
		self.mTextAlignment = NSTextAlignmentCenter;
		self.size = CGSizeZero;
		
		self.backgroundColor = [UIColor clearColor];
		
	}
	return self;
}

//frame被外界设置后,computedSize也应该发生改变.
//- (void)setFrame:(CGRect)frame {
//	if(!CGRectEqualToRect(frame, self.frame)) {
//		_frame = frame;
//		self.computedSize = frame.size;
//		[self doCompute];
//	}
//}

- (void)setSize:(CGSize)size {
	if(!CGSizeEqualToSize(size, self.size)) {
		_size = size;
		_computedSize = size;
		[self doCompute];
	}
}

//Compute,Calculate,还是选择Compute.计算属性computedProperty.
- (void)doCompute {
	self.btnFrame = [JsGeometryManager frameWithInsets:UIEdgeInsetsZero containerSize:self.size];
}



@end
